package cn.edu.sjtu.se.dslab.util;

import cn.edu.sjtu.se.dslab.auth.User;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class ClassParser {
	private Gson gson;

	public ClassParser() {
		gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
	}

	public String user2String(User user) {
		try {
			if (user != null) {
				String result = gson.toJson(user);
				return result;
			} else {
				return null;
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return null;
		}
	}
}
